package com.king.pattem.factory.abstractFactory;

import com.king.pattem.factory.abstractFactory.car.ICar;
import com.king.pattem.factory.abstractFactory.factory.IFactory;
import com.king.pattem.factory.abstractFactory.factory.impl.ProductFactoryByFactory;
import com.king.pattem.factory.abstractFactory.factory.impl.ProductFactoryByNew;
import com.king.pattem.factory.abstractFactory.plane.IPlane;

/**
 *	抽象工厂模式测试类 
 * @author taomk
 */
public class AbstractFactoryTest {

	public static void main(String[] args) {
		IFactory productFactory;
		ICar car;
		IPlane plane;
		
		try {
			
			System.out.println(" Abstract Factory Test ："); 
			
			System.out.println(" 1.ProductFactoryByNew Test ："); 
			productFactory = new ProductFactoryByNew();
			
			car = productFactory.buildCar();
			plane = productFactory.buildPlane();
			
			car.drive();
			plane.fly();
			
			System.out.println(" 2.ProductFactoryByFactory Test ："); 
			productFactory = new ProductFactoryByFactory();
			
			car = productFactory.buildCar();
			plane = productFactory.buildPlane();
			
			car.drive();
			plane.fly();
		} catch (Exception e) {
			e.printStackTrace();
		} 
	}
}
